import request from '@/api/useRequest'
const publicPath = '/users'
export function login(data: { username: string; password: string }): any {
  return request({
    url: `${publicPath}/login`,
    method: 'post',
    data,
    useCommonTip: true
  } as any)
}
export function getUserInfo() {
  return request({
    url: `${publicPath}/profile`,
    method: 'get'
  } as any)
}
// 注册接口
export function register(data: {
  username: string,
  password: string,
  code: string
}) {
  return request({
    url:  `${publicPath}/register`,
    method: 'post',
    data
  })
}
// 更新注册账号信息接口
export function changePassInfo(data: {
  username: string,
  newPassword: string,
  oldPassword: string
}) {
  return request({
    url: `${publicPath}/changePassInfo`,
    method: 'put',
    data,
    useCommonTip: true
  } as any)
}
// 管理员修改账号密码
export function resetUserPwd(data: any) {
  return request({
    url: `${publicPath}/adminChangePassInfo`,
    method: 'put',
    data,
    useCommonTip: true
  } as any)
}
